package TestSchoolSubjects1;

import SchoolSubjects3.*;
import java.io.*;

public class TestSchoolSubjects1 { // 测试类1
    public static void main(String[] args) throws IOException, ClassNotFoundException { // 程序入口
        Curriculums gaoshu = new Curriculums(1, "高等数学", "jiao101", "8:00"); // 创建课程类实例对象
        Curriculums wuli = new Curriculums(2, "物理", "jiao106", "13:00");
        Curriculums dianlu = new Curriculums(3, "电路模拟", "jiao201", "14:00");
        Curriculums xiandai = new Curriculums(4, "线性代数", "jiao202", "15:00");
        Curriculums lisan = new Curriculums(5, "离散数学", "jiao203", "16:00");
        Curriculums wulishiyan = new Curriculums(6, "物理实验", "jiao204", "17:00");

        Curriculums moren1[] = new Curriculums[6];
        Curriculums moren2[] = new Curriculums[6];
        Teachers Mrwang = new Teachers(1, "王老师", "男", moren1); // 创建教师类实例对象
        Teachers MsLi = new Teachers(2, "李老师", "女", moren2);

        Curriculums moren3[] = new Curriculums[6];
        Students StdWang = new Students(1, "学生汪", "男", moren3); // 创建学生类实例对象
        Curriculums moren4[] = new Curriculums[6];
        Students StdZhang = new Students(2, "学生张", "男", moren4);
        Curriculums moren5[] = new Curriculums[6];
        Students StdChen = new Students(3, "学生辰", "女", moren5);

        Mrwang.openCurriculums(Mrwang, 0, gaoshu); // 教师开课
        Mrwang.openCurriculums(Mrwang, 1, xiandai);
        Mrwang.openCurriculums(Mrwang, 2, lisan);
        MsLi.openCurriculums(MsLi, 0, wuli);
        MsLi.openCurriculums(MsLi, 1, dianlu);
        MsLi.openCurriculums(MsLi, 2, wulishiyan);

        StdWang.choiceCurriculums(StdWang, 0, gaoshu); // 学生选课
        StdWang.choiceCurriculums(StdWang, 1, wuli);
        StdWang.choiceCurriculums(StdWang, 2, dianlu);
        StdZhang.choiceCurriculums(StdZhang, 0, gaoshu);
        StdZhang.choiceCurriculums(StdZhang, 1, wuli);
        StdChen.choiceCurriculums(StdChen, 0, gaoshu);
        StdChen.choiceCurriculums(StdChen, 1, lisan);

        FileOutputStream fileOutputStream = new FileOutputStream(
                "D:\\java\\Teachers_start_classes_and_students_choose_classes.dat");
        try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
            objectOutputStream.writeObject(Mrwang);
            objectOutputStream.writeObject(MsLi);
            objectOutputStream.writeObject(StdWang);
            objectOutputStream.writeObject(StdZhang);
            objectOutputStream.writeObject(StdChen);
            objectOutputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        ;
    }
}